<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>

<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>项目支付表结清明细</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
	<div id="pageInTab" class="pageInTab">
	            <form id="formSet1">
	                <div class="fieldset1 tabel_col clearFix">
	                     <div class="fieldBox col_50">
		                    <div class="label">融资租赁合同号</div>
		                    <div class="field">
		                    <span>${prj.lsCntNo}</span>
		                   <input name="paySchId" id="paySchId" type="hidden" class="ui-textbox"   value="${paySchId}" >
		                    </div>
		                </div>
		                 <div class="fieldBox col_50">
		                    <div class="label">承租人</div>
		                    <div class="field">
		                       <span>${cst.cstNm }</span>
		                    </div>
		                </div>
		                  <div class="fieldBox col_50">
		                    <div class="label">支付表号</div>
		                    <div class="field">
		                          <a href="javascript:detailBtn()" class="link">
					  	    <span>${pay.paySchNo}</span>
				     	    </a>
		                    </div>
		                </div>
		                  <div class="fieldBox col_50">
		                    <div class="label">结清方式</div>
		                    <div class="field">
		                          <span id="settleWay" name="settleWay">提前结清</span>
		                    </div>
		                </div>
		                  <div class="fieldBox col_50">
		                    <div class="label">开始期次</div>
		                    <div class="field">
		                       <span>${pay.startLsPd}</span>
		                    </div>
		                </div>
		                 <div class="fieldBox col_50">
		                    <div class="label" role="ligertip" >自结清期剩余租金合计(元)</div>
		                    <div class="field">
		                    <span>
		                    <c:if test="${pay.lastRntAmt==0}">
		                       			0
		                      </c:if>
		                       <c:if test="${pay.lastRntAmt!=0}">
		                    <fmt:formatNumber  type="number" value="${pay.lastRntAmt}"  pattern=".00"/>
		                    </c:if>
		                    </span>
		                    </div>
		                </div> 
		                <!-- -->
		               <div class="fieldBox col_50">
		                    <div class="label">保险保证金处理状态</div>
		                    <div class="field">
		                       <span>${pay.insDepHandleWayCdNm}</span>
								 </div>
		                </div>
		                 <div class="fieldBox col_50">
		                    <div class="label">保险保证金(元)</div>
		                    <div class="field">
		                       <span>
		                       		<c:if test="${pay.insDep!=0}">
		                           <fmt:formatNumber type="number" value="${pay.insDep}"  pattern="#.00" />
		                       		</c:if>
		                       		<c:if test="${pay.insDep==0}">
		                       			0
		                       		</c:if>
		                      </span>
								 </div>
		                </div>
		                   <div class="fieldBox col_50">
		                    <div class="label">客户保证金处理状态</div>
		                    <div class="field">
		                       <span>${pay.detHandleWayCdNm}</span>
								 </div>
		                </div>
		                 <div class="fieldBox col_50">
		                    <div class="label">客户保证金(元)</div>
		                    <div class="field">
		                       <span>
		                        <c:if test="${pay.detAmt==0}">0</c:if>
		                       			 <c:if test="${pay.detAmt!=0}">
		                           <fmt:formatNumber type="number" value="${pay.detAmt}" pattern=".00" />
		                           </c:if>
		                     </span>
		                    </div>
		                </div>
		                
		                   <div class="fieldBox col_50">
		                    <div class="label">优惠金额(元)</div>
		                    <div class="field">
		                       <span>
		                       <c:if test="${pay.discountAmt==0}">0</c:if>
		                              <c:if test="${pay.discountAmt!=0}">
		                             <fmt:formatNumber type="number" value="${pay.discountAmt}"  pattern=".00" />
		                             </c:if>
		                   </span>
		                    </div>
		                </div>
		                 <div class="fieldBox col_50">
		                    <div class="label" role="ligertip" >结清前应还的每期租金合计(元)</div>
		                    <div class="field">
				                  <span>
				                     <c:if test="${pay.beforeSettRntAmt==0}">0</c:if>
				                    <c:if test="${pay.beforeSettRntAmt!=0}">
				                     <fmt:formatNumber type="number"  value="${pay.beforeSettRntAmt}" pattern=".00" />
				                     </c:if>
				                 </span>
		                    </div>
		                </div>
		                
		                 <div class="fieldBox col_50">
		                    <div class="label">违约金(元)</div>
		                    <div class="field">
		                  <span>
		                      <c:if test="${pay.breachAmt==0}">0</c:if>
		                      <c:if test="${pay.breachAmt!=0}">
		                  <fmt:formatNumber type="number" value="${pay.breachAmt}"  pattern=".00" />
		                  </c:if>
		               </span>
		                    </div>
		                </div>
		                <!-- 无逾期时显示 -->
		                    <div class="fieldBox col_50" id="beforeSetteRntAmt" style="display: none">
		                    <div class="label" role="ligertip" >未到支付日期已还款金额合计(元)</div>
		                    <div class="field">
		                  <span>
		                     <c:if test="${pay.beforeSettRntAmt==0}">0</c:if>
		                    <c:if test="${pay.beforeSettRntAmt!=0}">
		                    <fmt:formatNumber type="number" value="${pay.beforeSettRntAmt}" pattern=".00"/>
		                    </c:if>
		                  </span>
		                    </div>
		                </div>
		                  
	                    <div class="fieldBox col_100">
		                    <div class="label">最终应还金额公式</div>
		                    <div class="field"  >
		                    <c:if test="${pay.penaltyAmt!=0&&yzdgFlag==0}">
		                     <span style="color: red">结清前应还的每期租金合计 + 末期租金 + 违约金 + 罚息 + 其他费用 - 违约金减免 –未到支付日期已还款金额合计 + 未核销借款金额</span>
		                    </c:if>
		                    <c:if test="${pay.penaltyAmt==0&&yzdgFlag==0}">
		                     <span style="color: red">结清前应还的每期租金合计 + 自结清期剩余租金合计 + 逾期罚息 + 其他费用 - 保证金 - 保险保证金 - 逾期当期已还款金额 + 未核销借款金额</span>
		                    </c:if>
		                     <c:if test="${yzdgFlag==1}">
		                     <span style="color: red">逾期租金+应收罚息+剩余本金+剩余利息-优惠金额（租金总额百分比，看主合同7.4）</span>
		                    </c:if>
		                    </div>
		                </div>
		                <div class="fieldBox col_50">
		                    <div class="label">逾期期次</div>
		                    <div class="field">
		                        <span>${pay.overduePd}</span>
		                    </div>
		                </div>
		                 <div class="fieldBox col_50">
		                    <div class="label">到今天逾期租金(元)</div>
		                    <div class="field">
		                        <span>
		                           <c:if test="${pay.overdueAmt==0}">0</c:if>
		                            <c:if test="${pay.overdueAmt!=0}">
		                          <fmt:formatNumber type="number" value="${pay.overdueAmt}"  pattern=".00"/>
		                          </c:if>
		                       </span>
		                    </div>
		                </div>
		                  <div class="fieldBox col_50">
		                    <div class="label">逾期罚息</div>
		                    <div class="field">
		                        <span>
		                             <c:if test="${pay.penaltyAmt==0}">0</c:if>
		                              <c:if test="${pay.penaltyAmt!=0}">
		                         <fmt:formatNumber type="number" value="${pay.penaltyAmt}"  pattern=".00"/>
		                         </c:if>
		                     </span>
		                    </div>
		                </div>
		                  <div class="fieldBox col_50">
		                    <div class="label" role="ligertip" >逾期当期已还款金额(元)</div>
		                    <div class="field">
		                      <span>
		                          <c:if test="${pay.actualAmt==0}">0</c:if>
		                              <c:if test="${pay.actualAmt!=0}">
		                       <fmt:formatNumber type="number" value="${pay.actualAmt}"  pattern=".00"/>
		                       </c:if>
		                    </span>
		                    </div>
		                </div>
		           
		                 <div class="fieldBox col_100">
		                    <div class="label"> 最终应还金额(元)</div>
		                    <div class="field">
		                  <span>
		                      <c:if test="${pay.finalPayAmt==0}">0</c:if>
		                          <c:if test="${pay.finalPayAmt!=0}">
		                  <fmt:formatNumber type="number" value="${pay.finalPayAmt}"  pattern=".00"/>
		                  </c:if>
		                  
		               </span>
		                    </div>
		                </div>
		               
		                 <div class="caption">
                                <span class="title">已付款项明细信息</span>
                  	    </div>
                  	    
				        <div class="fieldBox col_100">
				            <div class="sqPanel">
				                <div id="detailGrid">
				                    <div id="ligergrid_fee" class="sq-grid"></div>
				                </div>
				            </div>
				        </div>
				        <%--    <div class="fieldBox col_50">
		                    <div class="label">首期款应收合计</div>
		                    <div class="field">
		                    <span>
		                       <c:if test="${pay.firstPayAmt==0}">0</c:if>
		                        <c:if test="${pay.firstPayAmt!=0}">
		                     <fmt:formatNumber type="number" value="${pay.firstPayAmt}"  pattern=".00"/>
		                     </c:if>
		                 </span>
		                    </div>
		                </div>
		                   <div class="fieldBox col_50">
		                    <div class="label">首期款已收合计</div>
		                    <div class="field">
		                    <span
		                    <c:if test="${pay.firstPayAmt!=pay.totalFirstPayAmt}"> style="color: red"</c:if>
		                    >
		                    <c:if test="${pay.totalFirstPayAmt==0}">0</c:if>
		                     <c:if test="${pay.totalFirstPayAmt!=0}">
		                      <fmt:formatNumber type="number" value="${pay.totalFirstPayAmt}" pattern=".00"/>
		                      </c:if>
		                   </span>
		                    </div>
		                </div> --%>
		                	
		           <%--       <div class="fieldBox col_100">
		                    <div class="label">本金</div>
		                    <div class="field">
		                    <span>${pay.totalPrinAmt}</span>
		                    </div>
		                </div>
		               <div class="fieldBox col_100">
		                    <div class="label">利息</div>
		                    <div class="field">
		                    <span>${pay.totalIntAmt}</span>
		                    </div>
		                </div>
		                <div class="fieldBox col_100">
		                    <div class="label">已交罚息合计</div>
		                    <div class="field">
		                    <span>${pay.payAmount}</span>
		                    </div>
		                </div> --%>
		                      <div class="fieldBox col_100">
				            <div class="sqPanel">
				                <div>
				                    <div id="ligergrid_payAmt" class="sq-grid sq-grid-noTitle"></div>
				                </div>
				            </div>
				        </div>
		                 <div class="fieldBox col_100">
		                    <div class="label">来款合计</div>
		                    <div class="field">
		                    <span>${pay.totalActPrinAmt+pay.totalActIntAmt}</span>
		                    </div>
		                </div>
		                
		                    <div class="fieldBox col_100">
				            <div class="sqPanel">
				                <div>
				                    <div id="ligergrid_shouldPay" class="sq-grid sq-grid-noTitle"></div>
				                </div>
				            </div>
				        </div>
		             <%--     <div class="fieldBox col_100">
		                    <div class="label">风险保证金</div>
		                    <div class="field">
		                    <span>${pay.rickDep}</span>
		                    </div>
		                </div>
		                  <div class="caption">
                                <span class="title">应还项目信息</span>
                  	    </div>
                  	      <div class="fieldBox col_100">
		                    <div class="label">截止发起日应交逾期租金</div>
		                    <div class="field">
		                    <span>${pay.overdueAmt-pay.actualAmt}</span>
		                    </div>
		                </div>
		                 <div class="fieldBox col_100">
		                    <div class="label">截止发起日应交逾期罚息</div>
		                    <div class="field">
		                    <span>${pay.penaltyAmt}</span>
		                    </div>
		                </div>
		                 <div class="fieldBox col_100">
		                    <div class="label">自结清期剩余本金</div>
		                    <div class="field">
		                    <span>${pay.lastPrintAmt}</span>
		                    </div>
		                </div>
		                 <div class="fieldBox col_100">
		                    <div class="label">自结清期剩余利息</div>
		                    <div class="field">
		                    <span>${pay.lastIntAmt}</span>
		                    </div>
		                </div>
		                <c:forEach items="${pay.subFeeAmtTotalList}" var="fee">
			                <div class="fieldBox col_100">
			                    <div class="label">${fee.feeTypCdNm }</div>
			                    <div class="field">
			                    <span>
			                    <c:if test="${fee.feeAmt!=0}">-</c:if>
			                    ${fee.feeAmt}
			                    </span>
			                    </div>
			                </div>
		                </c:forEach> --%>
		                <!-- 添加结清费用项 -->
		              <div class="fieldBox col_100">
				            <div class="sqPanel">
				                <div id="detailGrid">
				                    <div id="ligergrid_def_fee_sett" class="sq-grid"></div>
				                </div>
				            </div>
				        </div>
		              <div class="fieldBox col_100">
				            <div class="sqPanel">
				                <div id="detailGrid">
				                    <div id="ligergrid_fee_sett" class="sq-grid"></div>
				                </div>
				            </div>
				        </div>
				        
		                <div class="fieldBox col_100">
		                    <div class="label">应收结清款</div>
		                    <div class="field">
		                    <span>${pay.totalSettAmt}</span>
		                    </div>
		                </div>
		                <div class="caption">
                                <span class="title">核算金额校验</span>
                  	    </div>
                  	      <div class="fieldBox col_100">
				            <div class="sqPanel">
				                <div>
				                    <div id="ligergrid_checkAmt" class="sq-grid sq-grid-noTitle"></div>
				                </div>
				            </div>
				        </div>
				   
                  	<%--   <div class="fieldBox col_100">
		                    <div class="label">支付表本金合计</div>
		                    <div class="field">
		                    <span>${pay.totalPrinAmt}</span>
		                    </div>
		                </div>
		               <div class="fieldBox col_100">
		                    <div class="label">支付表利息合计</div>
		                    <div class="field">
		                    <span>${pay.totalIntAmt}</span>
		                    </div>
		                </div>
		                 <div class="fieldBox col_100">
		                    <div class="label">核算金额校验</div>
		                    <div class="field">
		                    <span>${pay.checkPayAmt}</span>
		                    </div>
		                </div> --%>
				          <div class="fieldBox col_100">
				            <div class="sqPanel">
				                <div id="feePayGrid">
				                    <div id="ligergrid_calculate" class="sq-grid"></div>
				                </div>
				            </div>
				        </div>
				         <div class="fieldBox col_33">
		                    <div class="label">合计租金</div>
		                    <div class="field">
		                    <span id="totalRntAmt">${pay.totalRntAmt}</span>
		                    </div>
		                </div>
		                 <div class="fieldBox col_33">
		                    <div class="label">合计本金</div>
		                    <div class="field">
		                    <span id="totalPrinAmt">${pay.totalPrinAmt}</span>
		                    </div>
		                </div>
		                 <div class="fieldBox col_33">
		                    <div class="label">合计利息</div>
		                    <div class="field">
		                    <span id="totalIntAmt">${pay.totalIntAmt}</span>
		                    </div>
		                </div>
		                  <div class="fieldBox col_50"   isYZDG="yzdg"  style="display: none">
		                    <div class="label">优惠开始期次</div>
		                    <div class="field">
		                       <select id="reduStartLsPd" disabled="disabled">
		                    <c:forEach begin="${pay.startLsPd}" end="${payPd}" step="1" var="pd">
		                    	<option value="${pd}"
		                    	<c:if test="${pd==reduStartLsPd}"> selected="selected"</c:if>
		                    	>第${pd}期</option>
		                    </c:forEach>
		                    </select>
		                    </div>
		                </div>
		                 <div class="fieldBox col_33"  isYZDG="yzdg"  style="display: none">
		                    <div class="label">开始结清期次12期（不含）之后剩余租金</div>
		                    <div class="field">
		                    <span id="totalIntAmt">${after12LastRntAmt}</span>
		                    </div>
		                </div>
		                  <div class="fieldBox col_50"   isYZDG="yzdg"  style="display: none">
		                    <div class="label">结清比例</div>
		                    <div class="field">
		                     <select name="settPct" id="settPct">
                                <c:forEach items="${settPctList}" var="opt">
                                    <option value="${opt.key}"
                                            <c:if test="${opt.key==settPctValue}">selected="selected"</c:if>
                                    >${opt.value}</option>
                                </c:forEach>
                            </select>
		                    </div>
		                </div>
		                  <div class="fieldBox col_33"   isYZDG="yzdg"  style="display: none">
		                    <div class="label">合同外优惠金额</div>
		                    <div class="field">
		                   <input name="extContAmt" id="extContAmt" type="text" class="ui-textbox"  value="${extContAmt}" readonly="readonly">
		                    </div>
		                </div>
		                  <div class="fieldBox col_33"   isYZDG="yzdg"  style="display: none">
		                    <div class="label">合同内优惠金额</div>
		                    <div class="field">
		                  <input name="reduAmt" id="reduAmt" type="text" class="ui-textbox"  value="${reduAmt-extContAmt}" readonly="readonly">
		                    </div>
		                </div>
		                <div class="fieldBox col_33"   isYZDG="yzdg"  style="display: none">
		                    <div class="label">优惠金额总计</div>
		                    <div class="field">
		                  <input name="reduTotalAmt" id="reduTotalAmt" type="text" class="ui-textbox"  value="${reduAmt}">
		                    </div>
		                </div>
		                      <div class="fieldset1 tabel_col tabel_col_s clearFix">
			                            <div class="caption">
			                                <span class="title">上传附件信息 </span>
			                            </div>
					          	           <div class="fieldBox col_100" id="fileModify">
			                    <div class="label">资料</div>
			                    <div class="field">
			                    	<input name="paySchId" id="paySchId" type="hidden" value="${pay.id }">
			                    	<jsp:include page="../../system/sysUlFilesRec/sysUlFileRecListDetail.jsp" flush="true" >
			                    		<jsp:param name="tabNm" value="PRJ_PRD_PAY_SCH_M"/>
			                    			<jsp:param name="pkId" value="${pay.id}"/>
			                    	</jsp:include>
			                    </div>
			          </div>
			           </div>
	                </div>
	            </form>
	            <!-- 支付表结清账号维护页面 -->
	            <c:if test="${showBk_oCIn==1 }">
		            <jsp:include page="../prjPrdPaySchBank/prjPrdPaySchBankAdd.jsp"></jsp:include>
	            </c:if>
	            <c:if test="${showBk_oCOut==1 }">
		            <jsp:include page="../prjPrdPaySchBank/prjPrdPaySchBankAdd1.jsp"></jsp:include>
	            </c:if>
	           	<!-- 客户开票页面 -->
	            <div id="cstPrdPayBillDiv">
			        <%-- dynamic div --%>
			    </div>
	</div>
</div>

<script type="text/javascript">
var feeGrid;//费用明细信息
var paySchId = '${paySchId}';
var wsPaySchId = '${pay.wsPaySchId}';
var calculateGrid;//支付明细
var feeSettGrid;//结清费用项
//var subFeeList='${pay.subFeeAmtDetilList}'; //结算时要减的费用项
var subFeeAmt = '${subFeeAmtTotalList}';
subFeeAmt = JSON.parse(subFeeAmt);
var payAmtGrid;
var shouldPayGrid;
var checkAmtGrid;
var feeSettGrid;//结清费用项
var defFeeSettGrid; //结清默认费用项
var yzdgFlag = '${yzdgFlag}';
//费用类型
var settFeeTypCdListJSON = [];
<c:if test="${not empty settFeeTypCdListJSON}"> settFeeTypCdListJSON = ${settFeeTypCdListJSON};</c:if>
$(function(){
	$('#formSet1').ligerForm({
        validate : true
	});
	if(yzdgFlag==1){
		   $("div[isYZDG='yzdg']").each(function () {
            $(this).show();
        });
		   if(liger.get("settPct")&&liger.get("settPct")!="undefined"){
				liger.get("settPct").setDisabled(true);
			}
	}
	var pay = '${pay}';
	var listPage = '${listPage}';
	var feeListPage = '${feeListPage}';

	
	var checkAmtData = {
            "rows": [
				{
                "feeTypCdNm": "支付表本金合计",
                "feeAmt": '${pay.totalPrinAmt}',
                "paidUpAmt": ""
				},
				{
                "feeTypCdNm": "支付表利息合计",
                "feeAmt": '${pay.totalIntAmt}',
                "paidUpAmt": ""
				},
				{
                "feeTypCdNm": "核算金额校验",
                "feeAmt": '${pay.checkPayAmt}',
                "paidUpAmt": ""
				}
				
				],
            "total": 3
        }
	var payAmtData = {
		      "rows": [
						{
		                "feeTypCdNm": "本金",
		                "feeAmt": '${pay.totalPrinAmt}',
		                "paidUpAmt": "${pay.totalActPrinAmt}"
						},
						{
		                "feeTypCdNm": "利息",
		                "feeAmt": '${pay.totalIntAmt}',
		                "paidUpAmt": "${pay.totalActIntAmt}"
						},
						{
		                "feeTypCdNm": "已交罚息合计",
		                "feeAmt": '${pay.penaltyAmt}',
		                "paidUpAmt": "${pay.payAmount}"
						}
						
						],
            "total": 3
        }
	
	var shouldPayData = {
            "rows": [
				{
                "feeTypCdNm": "风险保证金",
                "feeAmt": '${pay.rickDep}',
                "paidUpAmt": ""
				},
				{
                "feeTypCdNm": "截止发起日应交逾期租金",
                "feeAmt": '${pay.overdueAmt}',
                "paidUpAmt": ""
				},
				{
                "feeTypCdNm": "截止发起日应交逾期罚息",
                "feeAmt": '${pay.penaltyAmt}',
                "paidUpAmt": ""
				},
				{
                "feeTypCdNm": "自结清期剩余本金",
                "feeAmt": '${pay.lastPrintAmt}',
                "paidUpAmt": ""
				},
				
				{
                "feeTypCdNm": "自结清期剩余利息",
                "feeAmt": '${pay.lastIntAmt}',
                "paidUpAmt": ""
				}
				],
            "total": 0
        }
	for ( var i=0; i<subFeeAmt.length;i++) {
		  var obj = subFeeAmt[i];
		  var json = {};
		  json.feeTypCdNm=obj.feeTypCdNm;
		  json.feeAmt=obj.feeAmt;
		  json.paidUpAmt=obj.paidUpAmt;
		  json.capFlow = obj.capFlow;
		 shouldPayData.rows.push(json);
	  }	 
	
	
	
	listPage = JSON.parse(listPage);
	feeListPage = JSON.parse(feeListPage);
	prjQuatPrpsfeeGrid(feeListPage);
	initCalculatePage(listPage);
	prjQuatPrpsfeeSettGrid();
	prjQuatPrpsDefFeeSettGrid();
	prjPrdPayCheckAmtGrid(checkAmtData);
	prjPrdPayShouldPayGrid(shouldPayData);
	prjPrdPayPayAmtGrid(payAmtData);

	var penaltyAmt = '${pay.penaltyAmt}';
	if(penaltyAmt!=0){
		$("#beforeSetteRntAmt").show();
	}
	
	//初始化开票页面
	initBillPage();
});


function prjPrdPayCheckAmtGrid(data){
	checkAmtGrid = $("#ligergrid_checkAmt").ligerGrid({
        data: data,
        columns: [
        { display: '项目', name: 'feeTypCdNm', minWidth: 140 },
        { display: '应收金额(元)', name: 'feeAmt', minWidth: 140,render:renderAmt, type:'currency'},
        { display: '已收金额(元)', name: 'paidUpAmt',
      /*    	render: function (rowdata, rowindex, value, column) { 
         		var h = 0;
         		if(value){
        		 h = value/100;
         		}
                 return h;
        		}, */
        	minWidth: 60, type:'currency'}
        ],
        usePager: false,
        root: 'rows',
        record: 'total',
        hideLoadButton: true,
        width: '100%',
        heightDiff: -2,
        enabledEdit: false,
        isScroll: false,
        checkbox: false,
        rownumbers: true,
        frozen:false,
        allowUnSelectRow: false,
        alternatingRow: false
    });
}

function prjPrdPayShouldPayGrid(data){
	shouldPayGrid = $("#ligergrid_shouldPay").ligerGrid({
        data: data,
        columns: [
        { display: '项目', name: 'feeTypCdNm', minWidth: 140 },
        { display: '应收金额(元)', name: 'feeAmt', 
          	 render: function (item) {
        		 var amt = item.feeAmt;
        		 if(item.capFlow==ProjectConstant.CODE_PRJ_QUAT_CASH_FLOW_OUT){
        			 amt = "<span style='color:red'>-"+
        			 "￥" + FormatMoney((parseFloat(item.feeAmt)).toFixed(2))
        			+"</span>";
        		 }else{
        			 amt = "￥" + FormatMoney((parseFloat(item.feeAmt)).toFixed(2));
        		 }
                  return amt;
              },
        	minWidth: 140, type:'currency'},
        { display: '已收金额(元)', name: 'paidUpAmt', 
      /*     	render: function (rowdata, rowindex, value, column) { 
         		var h = 0;
         		if(value){
        		 h = value/100;
         		}
         		 h="￥" + FormatMoney((parseFloat(h)).toFixed(2));
                 return h;
        		}, */
        	minWidth: 60, type:'currency'}
        ],
        usePager: false,
        root: 'rows',
        record: 'total',
        hideLoadButton: true,
        width: '100%',
        heightDiff: -2,
        enabledEdit: false,
        isScroll: false,
        checkbox: false,
        rownumbers: true,
        frozen:false,
        allowUnSelectRow: false,
        alternatingRow: false
    });
}

function prjPrdPayPayAmtGrid(data){
	payAmtGrid = $("#ligergrid_payAmt").ligerGrid({
        data: data,
        columns: [
        { display: '项目', name: 'feeTypCdNm', minWidth: 140 },
        { display: '应收金额(元)', name: 'feeAmt', minWidth: 140, render:renderAmt},
        { display: '已收金额(元)', name: 'paidUpAmt',render:renderAmt,
   /*        	render: function (rowdata, rowindex, value, column) { 
         		var h = 0;
         		if(value){
        		 h = value/100;
         		}
         		 h="￥" + FormatMoney((parseFloat(h)).toFixed(2));
                 return h;
        		}, */
        	minWidth: 60, type:'currency'}
        ],
        usePager: false,
        root: 'rows',
        record: 'total',
        hideLoadButton: true,
        width: '100%',
        heightDiff: -2,
        enabledEdit: false,
        isScroll: false,
        checkbox: false,
        rownumbers: true,
        frozen:false,
        allowUnSelectRow: false,
        alternatingRow: false
    });
}


function prjQuatPrpsDefFeeSettGrid(){
	var  params = {};
	 params.paySchId = wsPaySchId;
	defFeeSettGrid = $("#ligergrid_def_fee_sett").ligerGrid({
	method : 'get',
	parms:params,
	url: '<%=path%>/project/prjPrdPaySchD/getPrjPrdPaySchDefSettFeeList.do',
    columns: [
        {display: '费用类型', name: 'feeTypCdNm', minWidth: 80},
        {display: '金额', name: 'feeAmt', minWidth: 80, type: 'numberbox',
        	render: function (item) {
       		 var amt = item.feeAmt;
       		 if(item.capFlow==ProjectConstant.CODE_PRJ_QUAT_CASH_FLOW_OUT){
       			 amt = "<span style='color:red'>-"+item.feeAmt+"</span>";
       		 }
       		 if(item.codeAttr1==ProjectConstant.CODE_PRJ_QUAT_CASH_FLOW_OUT){
       			 amt = "<span style='color:red'>-"+item.feeAmt+"</span>";
       		 }
                 return amt;
             }
        }
    ],
    usePager: false,
    pageSize:100,
    root: 'rows',
    record: 'total',
    hideLoadButton: true,
    width: '100%',
    height: 300,
    heightDiff: -2,
    enabledEdit: false,
    isScroll: false,
    checkbox: true,
    rownumbers: true,
    allowUnSelectRow: true,
    alternatingRow: true,
    usePagerOnLessPagesize: false,
});
}

function prjQuatPrpsfeeSettGrid(){
	var  params = {};
	       params.paySchId = wsPaySchId;
	       params.prjId = '${dtl.prjId}';
	feeSettGrid = $("#ligergrid_fee_sett").ligerGrid({
	method : 'get',
	parms:params,
	url: '<%=path%>/project/prjPrdPaySchD/getPrjPrdPaySchSettFeeList.do',
    columns: [
        {display: '费用类型', name: 'feeTypCdNm', minWidth: 80
        },
        {display: '金额', name: 'feeAmt', minWidth: 80, 
        	 render: function (item) {
                     var amt = item.feeAmt;

                     if(item.capFlow==ProjectConstant.CODE_PRJ_QUAT_CASH_FLOW_OUT){
                         amt = "<span style='color:red'>-"+
                             "￥" + FormatMoney((parseFloat(item.feeAmt)).toFixed(2))
                             +"</span>";
                     }
                     if(item.codeAttr1==ProjectConstant.CODE_PRJ_QUAT_CASH_FLOW_OUT){
                         amt = "<span style='color:red'>-"+
                             "￥" + FormatMoney((parseFloat(item.feeAmt)).toFixed(2))
                             +"</span>";
                     }
                     return amt;
              }
        },
        {display: '未核销金额', name: 'arAmt', minWidth: 80,
            render: function (item) {
                var amt = 0;
                amt = item.arAmt;
                if(StringUtils.isNotEmpty(amt)){
                    return '&yen;' + FormatMoney(amt / 100);
                }else{
                    return '';
                }
            }
        }
     
    ],
    usePager: false,
    pageSize:100,
    root: 'rows',
    record: 'total',
    hideLoadButton: true,
    width: '100%',
    height: 300,
    heightDiff: -2,
    isScroll: false,
    checkbox: false,
    rownumbers: true,
    allowUnSelectRow: true,
    alternatingRow: true,
    usePagerOnLessPagesize: false,
});
}


//格式化为人民币格式
function renderAmt(rowdata, rowindex, value) {
	if(null!==value&&value!=='undefined'&&value!==""){ 
	if(typeof Number(value)=='number'){
    var h="￥" + FormatMoney((parseFloat(value)).toFixed(2));
    return h;
	}
	} 
}

function prjQuatPrpsfeeGrid(data){
	feeGrid = $("#ligergrid_fee").ligerGrid({
        data: data,
        columns: [
        { display: '项目', name: 'feeTypCdNm', minWidth: 140 },
        { display: '应收金额(元)', name: 'feeAmt', minWidth: 140,render:renderAmt, type:'currency'},
        { display: '已收金额(元)', name: 'paidUpAmt', 
        	render: function (rowdata, rowindex, value, column) { 
         		var h = 0;
         		if(value){
        		 h = value/100;
         		}
         		  h="￥" + FormatMoney((parseFloat(h)).toFixed(2));
                 return h;
        		},
        	minWidth: 60}
        ],
        usePager: false,
        root: 'rows',
        record: 'total',
        hideLoadButton: true,
        width: '100%',
        height: 300,
        heightDiff: -2,
        enabledEdit: false,
        isScroll: false,
        checkbox: false,
        rownumbers: true,
        allowUnSelectRow: false,
        alternatingRow: false
    });
}
	function initCalculatePage(data){
		 	calculateGrid = $("#ligergrid_calculate").ligerGrid({
			data:data,
		     columns: [
		         { display: '支付时间', name: 'payDt', render:renderDate, minWidth: 60 },
		         { display: '期次', name: 'payPd',minWidth: 140},
		         { display: '租金', name: 'rntAmt', minWidth: 140,render:renderAmt, type:'currency',enabledSort:true},
		         { display: '本金', name: 'prinAmt', minWidth: 60, render:renderAmt,type:'currency'},
		         { display: '利息', name: 'intAmt', minWidth: 140, render:renderAmt,type:'currency' },
		         { display: '剩余本金', name: 'remPrinAmt', minWidth: 140,render:renderAmt, type:'currency' },
		     ],
		     usePager: false,
		     pageSize:10,
		     root:'rows',
		     record:'total',
		     hideLoadButton : true,
		     width: '100%',
		     height:300,
		     heightDiff:-2,
		     //isScroll: false,
		     checkbox:false,
		     enabledEdit: false,
		     rownumbers:true
		});
	}
	
	function detailBtn(prjPrdDtlId,paySchId,prjPrdId,prjId){
		var editFlag = true;
		var prjId = '${dtl.prjId}';
		var prjPrdDtlId = '${dtl.id}';
		var prjPrdId = '${dtl.prjPrdId}';
		var paySchId = '${paySchId}';
		Add_navTab('tab_prj_quat_prps'+paySchId,'查看支付表','<%=path%>/project/prjprdpayschm/toAddPage.do?prjId='+prjId+'&&id='+paySchId+'&&prjPrdDtlId='+prjPrdDtlId+'&&prjPrdId='+prjPrdId+'&&detailFlag='+editFlag);
	 }
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}
	
	//格式化为人民币格式
	function renderAmt(rowdata, rowindex, value) {
		if(null!==value&&value!=='undefined'&&value!==""){
		if(typeof Number(value)=='number'){
        var h="￥" + FormatMoney((parseFloat(value)).toFixed(2));
        return h;
		}
		} 
    }
	
	
	//初始化开票页面	
	function initBillPage(){
		var optba = '${optba}';
		var optbf = '${optbf}';
		var optbd = '${optbd}';
		/**
		* optba 标识是否需要开票新增列表页面_FUJINGRUN
        * optbf 标识是否显示财务开票列表页面_FUJINGRUN
        * optbd 是否显示开票详细列表页面_FUJINGRUN
		**/
		var _url = "";
		if(optba == 1){
			_url = "<%=path%>/customer/external/toClearPayPrjBillAppLyListPage.do";
		}else if(optbf == 1){
			_url = "<%=path%>/customer/external/toClearPayCstInvoiceFinanceListPage.do";
		}else if(optbd == 1){
			_url = "<%=path%>/customer/external/toClearPayCstInvoiceDetailListPage.do";
		}else{
			_url = "";
		}
		
		var _extPaySchMId = '${paySchId}';
		var _extPrjId = '${pay.prjId }';
		var _cstId = '${pay.cstId }';
		var _cstNm = '${cst.cstNm }';
		var _procInstId = '${procInstId}';
		if(StringUtils.isNotEmpty(_url)){
			var parms = {
					extPaySchMId: _extPaySchMId,
					extPrjId: _extPrjId,
					cstId: _cstId,
					cstNm: _cstNm,
					procInstId:_procInstId
			};
			//如果有参数则在第二个参数中传入
			$("#cstPrdPayBillDiv").load(_url, parms, function(responseText,textStatus){});
		}
	}
</script>



</body>
</html>
